angular.module('productInfo', []).controller('productInfoCtrl', [
    '$scope',
    'httpService',
    '$stateParams',
    'alertmsg',
    function($scope, httpService, $stateParams, alertmsg) {
        $(function(){
            $('body').bind('keypress',function(event){
                if (event.metaKey && (event.keyCode == 0 || event.keyCode == 112)) {
                    event.keyCode = 0;
                    return false;
                }
            });
        });

        // 获取当前订单的产品信息
        // 参数id
        var id = $stateParams.id
        // 产品信息
        $scope.products;
        // 照片信息
        $scope.productImgs;
        function getProductInfos() {
            httpService.query('web/generate_pdf', {id: id}).then(function(res) {
                console.log(res)
                if (res.code == 200) {
                    var item = res.pdf.lot.job.item;
                    var imgs = res.images;
                    if (item) {
                        $scope.products = item;
                        $scope.productImgs = imgs;
                        console.log($scope.products)
                    } else {
                        alertmsg('无产品信息！')
                    }
                }
            })
        }
        getProductInfos();

        $scope.printContent = function() {
          $("#print-content").print();
        }
    }
]);
